package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import view.AbstractGUI;
/**
 * this class is Graphic user interface of Costumer report, which extends AbstractGUI
 * @author jacob
 *
 */
public class CustomerReportGui extends AbstractGUI{
	
	protected JPanel CustomerReportPanel = null ;
	protected JScrollPane scroller = null;
	protected JTextArea textArea = null;
	protected Font myFont;
	protected String textDetail = "";
	/**
	 * Customer Report Constructor
	 */
	public CustomerReportGui(){
		super();
		CustomerReportPanel = new JPanel();
		initReport();
	}
	/**
	 * Initialize all the JTextArea, frame and panel 
	 */
	public void initReport(){
		textArea = new JTextArea("report",23,38);
		textArea.setFont(myFont = new Font("Serif",Font.BOLD,14));
		textArea.setEditable(false);
		setTitle(" Customer report ");
		//setBounds(150, 150, 300, 300);
	//	setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		 setSize(500, 600);
		setContentPane(getCustomerReportPanel());	
		
	}
/**
 *  set all the text on screen and create new intense of JScrollPane 
 *  that we can Scroll if the Details is more than our frame
 * @return JPanel
 */
	public JPanel getCustomerReportPanel() {
		setLayout(null);
        textArea.setText(textDetail);
        if(scroller == null){
        scroller = new JScrollPane(textArea);
        CustomerReportPanel.add(scroller);
        CustomerReportPanel.add(getBackB());
        CustomerReportPanel.setBackground(Color.lightGray);
        }
       
       setLocationRelativeTo ( null );
        setVisible(true);
		return CustomerReportPanel;
	}
	/*****************************************Getters and Setters of Labels, Buttons,TextFields *****************************/
	public JButton getBackB(){
		if(backButton == null){
			backButton = new JButton("Back to Manu");
			backButton.setBounds(80, 300, 80, 20);
		}
		return backButton;
	}
	public void setCustomerReportPanel(JPanel customerReportPanel) {
		CustomerReportPanel = customerReportPanel;
	}

	public JTextArea getTextArea() {
		return textArea;
	}

	public void setTextArea(JTextArea textArea) {
		this.textArea = textArea;
	}

	public String getStr() {
		return textDetail;
	}

	public void setStr(String str) {
		this.textDetail = str;
	}

	public JScrollPane getScroller() {
		return scroller;
	}
	
	/**
	 * add back button Action Listener
	 * @param listener
	 */
	public void addBackBottonCustomerreportActionListener(ActionListener listener){
		backButton.addActionListener(listener);

	} 


}
